<template>
  <base-breadcrumb>
    <searchData :searchData="searchOptions" @search="handleSearch" />
    <a-card>
      <titleName title="双优化立项情况"></titleName>
      <div class="table-operator">
        <a-button type="primary" @click="handleAdd">双优化计划审批</a-button>
        <div class="pub-table-select-count" style="margin: 10px 0">
          <a-icon type="info-circle" theme="twoTone" />
          <span>
            双优化计划项目:
            <a>{{ 0 || 0 }}个</a>，
          </span>
          <span>
            已立项:
            <a>{{ 0 || 0 }}个</a>，
          </span>
          <span>
            立项率为:
            <a>{{ 0 || 0 }}</a>
          </span>
        </div>
      </div>
      <s-table ref="table" row-key="id" :data="loadData" :columns="columns" bordered showPagination="auto">
        <span slot="description" slot-scope="text">
          <ellipsis :length="8" tooltip>{{ text }}</ellipsis>
        </span>
        <span slot="serial" slot-scope="text, record, index">{{ index + 1 }}</span>
      </s-table>
    </a-card>
  </base-breadcrumb>
</template>

<script>
import { STable } from '@/components'
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 项目
import { situation } from '@/api/technical/optimizationPlan'

const searchOptions = [
  {
    name: '所属分公司',
    valueKey: 'branchOffice',
    type: SelectSubCompany,
  },
  // {
  //   name: '所属项目',
  //   keyValue: 'branchOffice',
  //   valueKey: 'project',
  //   type: SelectProject,
  // },
  {
    name: '双优化名称',
    value: 'name',
    type: 'input',
  },
  {
    name: '计划实施时间',
    value: 'planTime',
    type: 'dateRange',
  },
  {
    name: '提出人',
    value: 'proposer',
    type: 'input',
  },
  {
    name: '立项状态',
    value: 'status',
    type: 'select',
    data: [
      {
        value: 1,
        label: '已经立项',
      },
      {
        value: 2,
        label: '未立项',
      },
    ],
  },
  {
    name: '实施时间',
    value: 'startTime',
    type: 'dateRange',
  },
  {
    name: '实施状态',
    value: 'properStatus',
    type: 'select',
    data: [
      {
        value: 1,
        label: '已经实施',
      },
      {
        value: 2,
        label: '未实施',
      },
    ],
  },
]

const columns = [
  {
    title: '序号',
    width: '30px',
    scopedSlots: { customRender: 'serial' },
  },
  {
    title: '项目名称',
    dataIndex: 'name',
  },
  {
    title: '双优化名称',
    dataIndex: 'doubleName',
  },
  {
    title: '双优分类',
    dataIndex: 'category',
  },
  {
    title: '内容概述',
    dataIndex: 'content',
  },
  {
    title: '计划实施时间',
    dataIndex: 'startTime',
  },
  {
    title: '提出人',
    dataIndex: 'proposer',
  },
  {
    title: '拟实施人',
    dataIndex: 'implementer',
  },
  {
    title: '预测效益（万元）',
    dataIndex: 'predictedBenefit',
  },
  {
    title: '立项状态',
    dataIndex: 'status',
  },
  {
    title: '立项时间',
    dataIndex: 'fillingTime',
  },
  {
    title: '实施状态',
    dataIndex: 'properStatus',
  },
  {
    title: '实施时间',
    dataIndex: 'properTime',
  },
]
export default {
    name:'a'+Date.now(),  components: {
    STable,
  },
  data() {
    this.columns = columns
    return {
      searchOptions: searchOptions,
      queryParam: {},
      loadData: (parameter) => {
        return situation({
          ...parameter,
          query: this.queryParam,
        })
      },
    }
  },
  methods: {
    handleSearch(val = {}) {
      this.queryParam = {
        ...val,
        startTimeBegin: (val.planTime && val.planTime.length && val.planTime[0].format('YYYY-MM-DD')) || void 0,
        startTimeEnd: (val.planTime && val.planTime.length && val.planTime[1].format('YYYY-MM-DD')) || void 0,
        properTimeBegin: (val.startTime && val.startTime.length && val.startTime[0].format('YYYY-MM-DD')) || void 0,
        properTimeEnd: (val.startTime && val.startTime.length && val.startTime[1].format('YYYY-MM-DD')) || void 0,
      }
      this.$refs.table.refresh(true)
    },
    handleAdd() {
      this.$router.push('/technical/optimizationPlan')
    },
  },
}
</script>

<style>
</style>
